﻿using IdentityService.Domain.Services;
using MediatR;

namespace IdentityService.Application.Commands
{
    public record ModifyPermitCommand(long Id, string Name, string Description) : IRequest<ModifyPermitResult>;

    public class ModifyPermitCommandHandler : IRequestHandler<ModifyPermitCommand, ModifyPermitResult>
    {
        private readonly IPermitService _permitService;
        public ModifyPermitCommandHandler(IPermitService permitService)
            => _permitService = permitService;

        public async Task<ModifyPermitResult> Handle(ModifyPermitCommand request, CancellationToken cancellationToken)
        {
            return await _permitService.ModifyAsync(request.Id, request.Name, request.Description);
        }
    }
}
